#!/usr/bin/env node

const arg = process.argv[2],
      log = console.log;
if(typeof(arg) === 'undefined' || arg === '--help' || arg == '-h') {
    help();
} else {
    calc();
}

function help() {
    log('\ usage: cmd-name [OPTION] [expression]\n\ evaluate the expression.\n\ \n\ Mandatory arguments to long options are mandatory for short options too.\n\ -h, -help output help information and exit');
}
 
function calc() {
  try {
    log(`${arg} = ${eval(arg)}`);
  } catch(e) {
    console.error(`${arg} 不是合法表达式！`);
  }
}
